* Appendix Table D5: Impact on fuel collection time driven by traditional fuel collection time

use "${output}panel_r0_r1_r2.dta", clear // Load merged analysis panel

********************************************************************************

* Keep households surveyed in each round
keep if sample_household == 1

********************************************************************************

* Analyses

local model_1 "i.treatment##i.surveyround"
local model_2 "i.treatment##i.chirag_strata##i.surveyround"
local estimation_options ", absorb(hh_id) vce(cluster uniquegrp)"

// Generate the fuel-collection time outcome variable
ren total_fuel_collection_time tot_fuel_coll_time
egen mean_fuel_coll = mean(tot_fuel_coll_time), by(surveyround)
replace tot_fuel_coll_time = mean_fuel_coll if mi(tot_fuel_coll_time)

// Replace missing values for traditional fuel collection time with surveyround-level mean
egen mean_trad_fuel_collection_time = mean(trad_fuel_collection_time), by(surveyround)
replace trad_fuel_collection_time = mean_trad_fuel_collection_time if mi(trad_fuel_collection_time)

estimates clear
foreach var of varlist tot_fuel_coll_time trad_fuel_collection_time {

	sum `var' if surveyround == 0 & treatment == 0 & chirag_strata == 0
	local `var'_m = `r(mean)'
	qui autofmt, input(``var'_m') dec(2) strict
	local `var'_m = `r(output1)'

	forval i = 1/2 {

		// Estimation
		qui reghdfe `var' `model_`i'' `estimation_options'
		estimates store `var'_`i'

		// Test of difference between two triple-diff. estimands
		capture noisily test 1.treatment#1.chirag_strata#1.surveyround = 1.treatment#1.chirag_strata#2.surveyround

	}
}

********************************************************************************

// Generate table (only reports triple-differences results)

estout tot_fuel_coll_time_2 trad_fuel_collection_time_2 ///
	using "${results}/apptable_impact_fuel_collection.tex", replace style(tex) ///
	cells("b(fmt(a2) star)" se(par fmt(a2))) ///
	keep(1.surveyround 2.surveyround ///
		1.treatment#1.surveyround 1.treatment#2.surveyround ///
		1.chirag_strata#1.surveyround 1.chirag_strata#2.surveyround ///
		1.treatment#1.chirag_strata#1.surveyround 1.treatment#1.chirag_strata#2.surveyround) ///
	stats(N r2_a, fmt(%15.0gc a2) labels("\(N\)" "Adjusted \(R^2\)")) ///
  	starlevels(* 0.10 ** 0.05 *** 0.01) ///
    collabels(none) mlabel(none) ///
	varlabels(1.surveyround "\({POST}_1\)" ///
			2.surveyround "\({POST}_2\)" ///
			1.treatment#1.surveyround "\({TREATMENT}_j \times {POST}_1\)" ///
			1.treatment#2.surveyround "\({TREATMENT}_j \times {POST}_2\)" ///
			1.chirag_strata#1.surveyround "\({NGO}_j \times {POST}_1\)" ///
			1.chirag_strata#2.surveyround "\({NGO}_j \times {POST}_2\)" ///
			1.treatment#1.chirag_strata#1.surveyround "\({TREATMENT}_j \times {NGO}_j \times {POST}_1\)" ///
			1.treatment#1.chirag_strata#2.surveyround "\({TREATMENT}_j \times {NGO}_j \times {POST}_2\)" ///
				, elist(1.surveyround " \addlinespace" ///
						2.surveyround " \addlinespace" ///
						1.treatment#1.surveyround " \addlinespace" ///
						1.treatment#2.surveyround " \addlinespace" ///
						1.chirag_strata#1.surveyround " \addlinespace" ///
						1.chirag_strata#2.surveyround " \addlinespace" ///
						1.treatment#1.chirag_strata#1.surveyround " \addlinespace") ///
				) ///
	prehead(  ///
		"\begin{table}[htbp]" ///
		"\centering" ///
		"\caption{Comparing impacts on fuel-collection time for all fuels and traditional fuels\label{app:fuel_collect_tab}}" ///
		"\begin{threeparttable}" ///
		"\begin{tabular}{l*{2}{c}}" ///
		"\toprule" ///
		"& (1) & (2) \\" ///
		"& \multicolumn{2}{c}{Fuel-collection time (minutes per day)} \\ \cmidrule{2-3}" ///
		"& All fuels & Traditional fuels \\" ///
		"\midrule" ///
		)  ///
	prefoot("\midrule" ///
		"Baseline non-NGO control mean & `tot_fuel_coll_time_m' & `trad_fuel_collection_time_m' \\" ///
		"Household fixed-effects & Yes & Yes \\" ///
		)  ///
	postfoot("\bottomrule" ///
			"\end{tabular}" ///
			"\begin{tablenotes}" ///
			"{\setlength\labelsep{0pt}" ///
			"\footnotesize" ///
			"\item \textit{Notes}. The outcome variable for fuel-collection time in column (1) is derived from self-reported data on time spent (per day, week, or month) collecting fuelwood, crop residue, leaves, dung, biomass pellets, kerosene, LPG, biogas, and---if relevant---any other fuel used by the household; the results in column (1) are identical to those presented in column (4) of Table \ref{t:impacts}. In column (2), fuel-collection time is restricted to only traditional fuels (fuelwood, crop residue, leaves, and dung). Standard errors (in parentheses) are clustered at the hamlet level. \sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\).}" ///
			"\end{tablenotes}" ///
			"\end{threeparttable}" ///
			"\end{table}" ///
		)
